﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ADAuthentication.Framework;
using System.Configuration;
using System.DirectoryServices;
using System.Collections;

namespace ADAuthentication.Web
{
    [Flags]
    public enum MappType
    { 
        User =1,

        Member =3
    }

    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MappType dd = MappType.Member;
            MappType type = (MappType)4;

            string adRootPath = ConfigurationManager.AppSettings["ADRootPath"];
            var allGroups = ActiveDirectoryHelper.GetGroupNames(adRootPath);
            ActiveDirectoryHelper.SynchronizeADInfoToUsers(adRootPath);
        }

        #region Button Click Events

        protected void CancelButton_Click(object sender, EventArgs e)
        {
        }

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            string adRootPath =ConfigurationManager.AppSettings["ADRootPath"];
            string adPath = ConfigurationManager.AppSettings["ADPath"];

            var allGroups = ActiveDirectoryHelper.GetGroupNames(adRootPath);
            var ddd = ActiveDirectoryHelper.GetUsers(adRootPath, "vpnusers");

            if (ActiveDirectoryHelper.IsAutheticated(adPath, DomainTextBox.Text, UserNameTextBox.Text, PasswordTextBox.Text))
            {
                Response.Redirect("~/Default.aspx");
            }
        }

        #endregion
         
    }
}